defmodule Neo4jKeepAlive do
    @moduledoc """
        neo4j 保活进程
    """

    use GenServer

    def start_link(_) do
        GenServer.start_link(__MODULE__, [], name: __MODULE__)
    end

    def running() do
        GenServer.cast(__MODULE__, :running)
    end

    def init(_opts) do
        {:ok, %{}, AppConfigure.fetch("bolt_idel_interval")}
    end

    def handle_call(_msg, _from, state) do
        {:reply, :ok, state}
    end

    def handle_cast(:running, state) do
        {:noreply, state, AppConfigure.fetch("bolt_idel_interval")}
    end
    def handle_cast(_msg, state) do
        {:noreply, state}
    end

    def handle_info(:timeout, state) do
        Neo4jDb.query("return 'ok'")
        {:noreply, state, AppConfigure.fetch("bolt_idel_interval")}
    end
    def handle_info(_msg, state) do
        {:noreply, state}
    end


end
